<%= section_panel 'Components', :id => 'components_list', :width => 'single', :position => 'right' do %>
  <% toolbar = {:list_name => 'operations_platform_components',
                :sort_by   => [%w(Name ciName), %w(Health health)],
                :filter_by => %w(ciName health),
                :compact   => false} %>
  <%= ci_list(@requires.map(&:toCi).sort_by(&:ciClassName), :toolbar => toolbar) do |builder, target| %>
    <% health = target.health
       state = nil
       if health
         state = 'unknown'
         %w(unhealthy overutilized notify underutilized good).each do |s|
           if health[s] && health[s] > 0
             state = s
             break
           end
         end
       end %>
    <% builder.attributes %(ciName="#{target.ciName}" health="#{state}") %>
    <% builder.target link_to('', assembly_operations_environment_platform_component_path(@assembly, @environment, @platform, target)) %>
    <% builder.icon ci_image_url(target) %>
    <% if target.ciAttributes.attributes.present? %>
      <% builder.middle do %>
        <%= render 'cms/cis/important', :ci => target %>
      <% end %>
    <% end %>
    <% builder.status do %>
      <% if health %>
        <%= content = health.inject('') {|c, (s, count)| c + "<span class='#{health_to_text(s)}'><strong>#{count}</strong> #{s}</span><br>"}
            status_marker('health', state, health_to_label(state), 'data-toggle' => 'popover', 'data-html' => true, 'data-title' => 'Intance Counts by State', 'data-content' => content, 'data-trigger' => 'click', 'data-placement' => 'bottom') %>
      <% end %>
      <% if @policy_compliance %>
        <% violate_count = @policy_compliance[target.ciId] %>
        <% if violate_count == 0 %>
          <%= status_marker('policy', 'passed', 'label-success') %>
        <% else %>
          <%= status_marker('policy', "#{violate_count} failed", 'label-important') %>
        <% end %>
      <% end %>
      <%= status_marker('release', target.rfcAction, action_to_label(target.rfcAction)) if target.rfcAction.present? %>
    <% end %>
    <% builder.bottom :none %>
  <% end %>
<% end %>

<%= section_panel 'Platform Health', :width => 'double', :position => 'left' do %>
  <ul class="status">
    <%= render 'base/shared/status_health',
               :scope        => 'platform',
               :state_counts => @ops_state_counts,
               :bom_status   => @bom_release ? 'pending' : 'disabled' %>
  </ul>
<% end %>

<%= section_panel 'Platform Status', :width => 'double', :position => 'left' do %>
  <ul class="status">
    <li id="status_autocomply" class="status-marker">
      <%= render 'status_autocomply' %>
    </li>
    <li id="status_autorepair" class="status-marker">
      <%= render 'status_autorepair' %>
    </li>
    <li id="status_autoreplace" class="status-marker">
      <%= render 'status_autoreplace' %>
    </li>
    <% if @platform.ciAttributes.availability == 'redundant' %>
      <li id="status_autoscale" class="status-marker">
      	<%= render 'status_autoscale' %>
      </li>
    <% end %>
  </ul>
<% end %>

<% if @clouds.present? %>
  <%= section_panel 'Cloud Status', :width => 'double', :position => 'left' do %>
    <%= render 'transition/platforms/cloud_status' %>
  <% end %>
<% end %>
